package api

import (
	"api/basic/config"
	__ "api/basic/proto"
	"api/handler/request"
	"github.com/gin-gonic/gin"
	"net/http"
	"strconv"
)

func Member(c *gin.Context) {
	var form request.Member
	// 根据 Content-Type Header 推断使用哪个绑定器。
	if err := c.ShouldBind(&form); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	member, err := config.Client.Member(c, &__.MemberReq{
		Right:  form.Right,
		Money:  strconv.Itoa(form.Money),
		Status: form.Status,
	})
	if err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 400,
			"msg":  "会员续费提醒",
			"data": nil,
		})
		return
	} else {
		c.JSON(http.StatusOK, gin.H{
			"code": 200,
			"msg":  "查询成功",
			"data": member,
		})
	}
}
